package com.example;

import java.util.Collections;
import java.util.List;
import javax.net.ssl.SNIServerName;

class ServerNameSpec {
    final List<SNIServerName> serverNames;

    ServerNameSpec(List<SNIServerName> serverNames) {
        this.serverNames = Collections.<SNIServerName>unmodifiableList(serverNames);
    }

    public String toString() {
        if (serverNames == null || serverNames.isEmpty())
            return "<no server name indicator specified>";

        StringBuilder builder = new StringBuilder(512);
        serverNames.stream().map((sn) -> {
            builder.append(sn.toString());
            return sn;
        }).forEachOrdered((_item) -> {
            builder.append("\n");
        });

        return builder.toString();
    }
}
